﻿<!--#Include File="LoginCheck.asp"-->
<!--#Include File="Conn.asp"-->
<%

	'=============汉字转换为UTF-8================== 
	function chinese2unicode(Str) 
	for i=1 to len(Str) 
	Str_one=Mid(Str,i,1) 
	Str_unicode=Str_unicode&chr(38) 
	Str_unicode=Str_unicode&chr(35) 
	Str_unicode=Str_unicode&chr(120) 
	Str_unicode=Str_unicode& Hex(ascw(Str_one)) 
	Str_unicode=Str_unicode&chr(59) 
	next 
	chinese2unicode = Str_unicode 
	end function 



	Dim Col,Val
	ptype = Request("ptype")
	num = Request("num")
	id = Request("id")
	flag = Request("flag")
	
	'response.Write(ptype&"-"&num&"-"&flag)
	if flag = "0" then		'提取数据
		set cmdObject = Server.CreateObject("ADODB.Command")
		with cmdObject
			.ActiveConnection = Conn         
			.CommandText      = "[FormatPrizeResults-03]"  
			.CommandType      = 4            
			.Prepared         = true
			set rs = .Execute
		end with
		set cmdObject=nothing
		set rs = nothing
	elseif flag = "1" then		'提取数据
		set cmdObject = Server.CreateObject("ADODB.Command")
		with cmdObject
			.ActiveConnection = Conn         
			.CommandText      = "[GetPrizeResults-03]"  
			.CommandType      = 4            
			.Prepared         = true
			.Parameters.append .CreateParameter("@Num",200,1,50,num)
			set rs = .Execute
		end with
		set cmdObject=nothing
		If rs.BOF And rs.EOF Then
			Response.Write("0")
		Else
			Do While not rs.Eof 
			Response.Write("<li id='t"&rs("PKID")&"'>"&chinese2unicode(rs("Name"))&"#"&rs("Email")&"</li>")
			rs.movenext
			Loop			
		End If
		set rs = nothing
	elseif flag = "2" then	'抽奖
		set cmdObject = Server.CreateObject("ADODB.Command")
		with cmdObject
			.ActiveConnection = Conn         
			.CommandText      = "[GetPrizeResults-03]"  
			.CommandType      = 4            
			.Prepared         = true
			.Parameters.append .CreateParameter("@Num",200,1,50,num)
			set rs = .Execute
		end with
		set cmdObject=nothing
		If rs.BOF And rs.EOF Then
			Response.Write("0")
		Else
			Do While not rs.Eof 
			Response.Write("<div id='t"&rs("PKID")&"'>"&chinese2unicode(rs("Name"))&"</div><div>"&rs("Email")&"</div><br />")
			rs.movenext
			Loop			
		End If
		set rs = nothing
	elseif flag = "3" then	'保存
		set cmdObject = Server.CreateObject("ADODB.Command")
		with cmdObject
			.ActiveConnection = Conn         
			.CommandText      = "[InsertPrizeResults-03]"  
			.CommandType      = 4            
			.Prepared         = true
			.Parameters.append .CreateParameter("@CustomerID",200,1,50,id)
			.Parameters.append .CreateParameter("@PrizeType",200,1,50,ptype)
			set rs = .Execute
		end with
		set cmdObject=nothing
		set rs = nothing
	else
	
	end if
%>